package com.lcf.system.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.lcf.framework.utils.UserUtils;
import com.lcf.framework.vo.PageVO;
import com.lcf.system.dao.PriceRecordDao;
import com.lcf.system.entity.PriceRecord;
import com.lcf.system.query.PriceRecordPageQuery;
import com.lcf.system.service.PriceRecordService;
import com.lcf.system.vo.PriceRecordVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * 收入记录(PriceRecord)表服务实现类
 *
 * @author lcf
 * @since 2025-05-02 11:55:02
 */
@Service("priceRecordService")
public class PriceRecordServiceImpl extends ServiceImpl<PriceRecordDao, PriceRecord> implements PriceRecordService {
    @Override
    public PageVO<PriceRecordVO> getPriceRecord(PriceRecordPageQuery query) {
        Page<PriceRecord> page = Db.lambdaQuery(PriceRecord.class)
                .eq(StringUtils.isNotBlank(query.getOrderNo()), PriceRecord::getOrderNo, query.getOrderNo())
                .eq(PriceRecord::getUserId, UserUtils.getUserId())
                .orderByDesc(PriceRecord::getCreateTime)
                .page(query.toPage());

        return new PageVO<>(page, PriceRecordVO.class);
    }
}

